package com.lonewalker.sparrow.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * 序列化Long类型
 *
 * @author lonewalker
 * @since 1.0
 */
public class LongJsonSerializer extends JsonSerializer<Long> {
    @Override
    public void serialize(Long value, JsonGenerator jsonGenerator, SerializerProvider serializers) throws IOException {
        String text = value == null ? null : String.valueOf(value);
        if (text != null) {
            jsonGenerator.writeString(text);
        }
    }
}
